package covertjava.nativecode;

/**
 * <p>Uses a native library to obtain and print OS memory information</p>
 * <p>Copyright: Copyright (c) 2004 Sams Publishing</p>
 * @author Alex Kalinovsky
 * @version 1.0
 */
public class OSMemoryInfo {
    static {
        try {
            System.loadLibrary("OSMemoryInfo");
        } catch (Exception x) {
            System.err.println("Error while loading native library OSMemoryInfo");
            x.printStackTrace(System.err);
            System.exit(1);
        }
    }

    public static void main(String args[]) {
        System.out.println("Total     Physical Memory: " + getPhysicalTotal());
        System.out.println("Available Physical Memory: " + getPhysicalAvail());
        System.out.println("Total     Virtual  Memory: " + getVirtualTotal());
        System.out.println("Available Virtual  Memory: " + getVirtualAvail());
    }

    public native static long getPhysicalTotal();
    public native static long getPhysicalAvail();
    public native static long getVirtualTotal();
    public native static long getVirtualAvail();
}
